<?php
use pc\models\News;
use yii\helpers\Url;
$HotNews = News::getMaxViewNews(1,10,['id','image','title','desc','create_time','view'])['data'];
?>
<!--热门排行-->
<div class="r_box2 mt20">
    <h3><span>热门排行</span></h3>
    <ul class="txtph_list mt20">
        <?php foreach ($HotNews as $key => $newInfo):?>
        <li <?php if($key == 0) echo 'class="cur"';?>>
            <a href="<?=Url::to("/news/{$newInfo['id']}.html");?>">
                <div class="txtph_1">
                    <?php if($key < 3):?>
                    <em class="fc1"><?=$key + 1?>.</em>
                    <?php else:?>
                        <?=$key + 1?>.
                    <?php endif;?>

                    <?=$newInfo['title']?></div>
                <div class="txtph_2">
                    <img src="<?=$newInfo['image']?>" />
                    <p><?=$newInfo['desc']?></p>
                </div>
            </a>
        </li>
        <?php endforeach;?>

    </ul>
</div>

<script>
    $(function(){
        $(".txtph_list li").each(function(){
            $(this).hover(function(){
                $(".txtph_list li").removeClass("cur");
                $(this).addClass("cur");
            })
        })

    })
</script>